//兼容crypto.randomUUID
const Global =
  (typeof self === 'object' && self.self === self && self) ||
  (typeof global === 'object' && global.global === global && global) ||
  this;
if (Global && Global.crypto && Global.crypto.randomUUID) {
  Global.crypto.randomUUID = Global.crypto.randomUUID.bind(Global.crypto);
} else {
  Global.crypto.randomUUID = function () {
    /**
     * 生成以上功能
     */
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(
      /[xy]/g,
      function (c) {
        const r = (Math.random() * 16) | 0;
        const v = c === 'x' ? r : (r & 0x3) | 0x8;
        return v.toString(16);
      },
    ) as `${string}-${string}-${string}-${string}-${string}`;
  };
}
